<?php	namespace Home\Model;
use Hdphp\Model\Model;
/**
 * 商品详情页评论管理模型
 * @author 武斌   <wubin.mail@foxmail.com>
 */
class Comment extends Model
{
	protected $table = 'comment';
	
	/**
	 * 添加评论
	 */
	public function addData()
	{
		//执行自动验证
		if(!$this->create()) return false;
		$gid = $_SESSION['gid'];
		if($_FILES['pic']['error'] != 4){
			$file = Upload::path('Upload/comment/' . date('Y/m/d'))->make();
			$this->data['pic'] = $file[0]['path'];
		}else
		{
			$this->error = '请重新上传图片';
		}
		$this->data['user_uid'] = $_SESSION['uid'];
		$this->data['time'] = time();
		$this->data['goods_gid'] = $gid;
		$this->add();
		return true;
	}
}
